package kernel.stl;

/**
 *
 * @author George
 */
public class Vector {
    
    private double x;
    private double y;
    private double z;
    
    public Vector(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    public double distanceTo(Vector otherVector) {        
        double deltaX = Math.abs(this.getX() - otherVector.getX());
        double deltaY = Math.abs(this.getY() - otherVector.getY());
        double deltaZ = Math.abs(this.getZ() - otherVector.getZ());
        
        return (double) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);        
    }
    
    public boolean equals(Vector otherVector, double tolerance) {
        if (this.distanceTo(otherVector) > tolerance)
            return false;
        else
            return true;        
    }
    
    public double getX() {
        return this.x;        
    }
    
    public double getY() {
        return this.y;
    }
    
    public double getZ() {
        return this.z;
    }
    
    public PointXYZ toVertex() {
        PointXYZ v = new PointXYZ(getX(), getY(), getZ()); 
        return v;
    }

}
